package info.hexin.quartz.redis;

import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2016/1/29.
 */
public interface RedisClient {
    public Boolean zadd(String key, Double score, Object req);

    public Boolean hasKey(String key);

    public Set<Object> zrange(String key, Long start, Long end);

    public Long removeRangeByScore(String key, Double min, Double max);

    public Boolean expire(String key, Integer timeout, String timeUnit);

    public Double incr(String key);

    public void delete(String key);

    public void delete(Collection key);

    public Object get(String key);

    public void set(String key, Object o);

    public void hSet(Object key, Object field, Object value);

    void hRemove(Object key, Object... fields);

    public Object hGet(Object key, Object field);

    public List hvals(Object key);

    /**
     * set 有实效性的数据，超过该时间数据过期，不在内存中，dump到 swap 中
     *
     * @param key
     * @param obj
     * @param time 有效时长
     */
    public void set(String key, Object obj, long time, String timeUnit);

    Long getSetSize(String key);

    Long getListSize(String key);

    Long getHashSize(String key);

    /**
     * 获取给定分数区间内的多个元素
     *
     * @param key
     * @param min
     * @param max
     * @param offset
     * @param count
     * @return
     */
    public Set<Object> zPopByScore(String key, Double min, Double max, Long offset, Long count);

    /**
     * list压栈
     *
     * @param key
     * @param val
     * @return
     */
    Long listLeftPush(String key, Object val);

    /**
     * list 出栈
     *
     * @param key
     * @param start
     * @param end
     * @return
     */
    List listRange(String key, long start, long end);

    /**
     * list 出栈
     *
     * @param key
     * @param start
     * @param end
     * @return
     */
    List listRange(String key, long start, long end, boolean isLog);



    Long getExpire(String key, TimeUnit timeUnit);

    public boolean setNx(String key, Object value);

    public boolean setNx(String key, Object value, Integer timeout, String timeUnit);

    Object getSet(String key, Object value);


    /**
     * 一个用户一天内的流水号
     *
     * @param userDay userId+shortDate
     * @return
     */
    Integer getUserDaySeq(String userDay);

    /**
     * 批量查询key对应的value
     * @param keys  需要查询的key列表
     * @return  查询到的value列表，长度和key列表长度一致，对于没查到的key，其对应的value为空
     */
    List mGet(List<String> keys);
}
